/**
 * Company : Siangklom.
 * Created By : Chatree Siangklom
 * Created On : Aug 26, 2013  3:45:51 PM 
 * e-Mail : dr_chatree@hotmail.com
 * Mobile Phone : (+66) 087-921-5115
 * Package Name : com.tis.database.services.impl
 * File Name : SdCustomerOutb1DaoServiceImpl.java
 * TODO
 */
package com.tis.database.services.staging.impl;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

import org.hibernate.HibernateException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import sap.business.enumeration.STAGING_STATUS;

import com.tis.database.dao.staging.SdCustomerOutb1Dao;
import com.tis.database.entitys.SapMessage;
import com.tis.database.entitys.staging.SdCustomerOutb1;
import com.tis.database.entitys.staging.StampObject;
import com.tis.database.services.staging.ISdCustomerOutb1Services;

/**
 * @author Administrator
 *
 */
@Service
@Transactional(readOnly = true)
public class SdCustomerOutb1ServicesImpl implements ISdCustomerOutb1Services {
	
	@Autowired 
	private SdCustomerOutb1Dao sdCustomerOutb1Dao;

	/* (non-Javadoc)
	 * @see com.tis.database.services.SdCustomerOutb1DaoService#RefreshObject(java.util.List)
	 */
	@Override
	public List<SdCustomerOutb1> RefreshObject(List<SdCustomerOutb1> sdCustomerOutb1List) throws HibernateException, Exception {
		return sdCustomerOutb1Dao.RefreshObject(sdCustomerOutb1List);
	}

	/* (non-Javadoc)
	 * @see com.tis.database.services.SdCustomerOutb1DaoService#findAllList()
	 */
	@Override
	public List<SdCustomerOutb1> findAllList() throws HibernateException, Exception {
		return sdCustomerOutb1Dao.findByAll(0);
	}

	/* (non-Javadoc)
	 * @see com.tis.database.services.SdCustomerOutb1DaoService#findByCustomerCode(java.lang.String)
	 */
	@Override
	public List<SdCustomerOutb1> findByCustomerCode(String code) throws HibernateException, Exception {
		return sdCustomerOutb1Dao.findCustomerByCode(code);
	}

	/** (Javadoc)
	 * @see com.tis.database.services.staging.ISdCustomerOutb1Services#Search(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
	 * Date =Sep 18, 2013 : 4:55:13 PM 
	 * CreateBy=Chatree Siangklom
	 * TODO
	 */
	@Override
	public List<SdCustomerOutb1> Search(String stagingId,									
			String customer,
			String name,
			String idNo,
			String taxId,
			String instanceNo,
			String syncCreatedOnStart,
			String syncCreatedOnEnd,
			int maxResult) throws HibernateException, Exception {

		return sdCustomerOutb1Dao.Search(stagingId, customer, name, idNo, taxId, instanceNo, syncCreatedOnStart, syncCreatedOnEnd, maxResult);
	}

	@Override
	@Transactional(readOnly = false)
	public void saveOrUpdate(List<SdCustomerOutb1> e) throws HibernateException {
		sdCustomerOutb1Dao.saveOrUpdate(e);		
	}

	@Override
	@Transactional(readOnly = false)
	public void saveOrUpdate(SdCustomerOutb1 e) throws HibernateException {
		sdCustomerOutb1Dao.saveOrUpdate(e);		
	}

	@Override
	@Transactional(readOnly = false)
	public void delete(List<SdCustomerOutb1> e) throws HibernateException {
		sdCustomerOutb1Dao.delete(e);
	}

	@Override
	@Transactional(readOnly = false)
	public void delete(SdCustomerOutb1 e) throws HibernateException {
		sdCustomerOutb1Dao.delete(e);
	}

	/** (Javadoc)
	 * @see com.tis.database.services.staging.ISdCustomerOutb1Services#NextSequence()
	 * Date =Oct 16, 2013 : 10:33:48 AM 
	 * CreateBy=Chatree Siangklom
	 * TODO
	 */
	@Override
	@Transactional(readOnly = false)
	public BigDecimal NextSequence() throws HibernateException, Exception {
		return sdCustomerOutb1Dao.NextSequence("CUSTOMER_OUTB");
	}

	/** (Javadoc)
	 * @see com.tis.database.services.staging.ISdCustomerOutb1Services#findByName(java.lang.String)
	 * Date =Oct 17, 2013 : 12:02:39 PM 
	 * CreateBy=Chatree Siangklom
	 * TODO
	 */
	@Override
	public List<SdCustomerOutb1> findByName(String name) throws Exception, HibernateException {
		
		return sdCustomerOutb1Dao.findByName(name);
	}

	/** (Javadoc)
	 * @see com.tis.database.services.staging.ISdCustomerOutb1Services#getCurrentDatabaseDate()
	 * Date =Oct 18, 2013 : 11:51:12 AM 
	 * CreateBy=Chatree Siangklom
	 * TODO
	 */
	@Override
	public Date getCurrentDatabaseDate() throws HibernateException, Exception {
		// TODO Auto-generated method stub
		return sdCustomerOutb1Dao.getCurrentDatabaseDate();
	}

	/** (Javadoc)
	 * @see com.tis.database.services.staging.ISdCustomerOutb1Services#StampUsedTime(com.tis.database.entitys.staging.StampObject, com.tis.database.entitys.staging.SdCustomerOutb1)
	 * Date =Oct 18, 2013 : 11:51:12 AM 
	 * CreateBy=Chatree Siangklom
	 * TODO
	 */
	@Override
	@Transactional(readOnly=false)
	public void StampUsedTime(StampObject stampObject, SdCustomerOutb1 e) throws Exception {
		// TODO Auto-generated method stub
		
		sdCustomerOutb1Dao.StampUsedTime(stampObject, e);
	}

	/** (Javadoc)
	 * @see com.tis.database.services.staging.ISdCustomerOutb1Services#StampUsedTimePROC(java.lang.String, java.util.Date, java.util.Date, com.tis.database.entitys.staging.SdCustomerOutb1)
	 * Date =Oct 18, 2013 : 1:38:44 PM 
	 * CreateBy=Chatree Siangklom
	 * TODO
	 */
	@Override
	public void StampUsedTimePROC(String instanceNo, Date procStartTime, Date procEndTime, SdCustomerOutb1 e) throws Exception {

		sdCustomerOutb1Dao.StampUsedTimePROC(instanceNo, procStartTime, procEndTime, e);
	}

	/** (Javadoc)
	 * @see com.tis.database.services.staging.ISdCustomerOutb1Services#StampUsedTimeSend(java.lang.String, java.util.Date, java.util.Date, com.tis.database.entitys.staging.SdCustomerOutb1)
	 * Date =Oct 18, 2013 : 1:38:44 PM 
	 * CreateBy=Chatree Siangklom
	 * TODO
	 */
	@Override
	public void StampUsedTimeSend(String instanceNo, Date sendUseStart, Date sendUseEnd, SdCustomerOutb1 e) throws Exception {
		sdCustomerOutb1Dao.StampUsedTimeSend(instanceNo, sendUseStart, sendUseEnd, e);
	}

	/** (Javadoc)
	 * @see com.tis.database.services.staging.ISdCustomerOutb1Services#StampUsedTimePms(java.lang.String, java.util.Date, java.util.Date, com.tis.database.entitys.staging.SdCustomerOutb1)
	 * Date =Oct 18, 2013 : 1:38:44 PM 
	 * CreateBy=Chatree Siangklom
	 * TODO
	 */
	@Override
	public void StampUsedTimePms(String instanceNo, Date pmsUseStart, Date pmsUseEnd, SdCustomerOutb1 e) throws Exception {

		sdCustomerOutb1Dao.StampUsedTimePms(instanceNo, pmsUseStart, pmsUseEnd, e);
	}

	/** (Javadoc)
	 * @see com.tis.database.services.staging.ISdCustomerOutb1Services#findByInstanceNo(java.lang.String, com.tis.database.entitys.staging.SdCustomerOutb1)
	 * Date =Oct 18, 2013 : 2:32:33 PM 
	 * CreateBy=Chatree Siangklom
	 * TODO
	 */
	@Override
	public List<SdCustomerOutb1> findByInstanceNo(String instanceNo, SdCustomerOutb1 e) throws HibernateException, Exception {

		return sdCustomerOutb1Dao.findByInstanceNo(instanceNo, e);
	}

	/** (Javadoc)
	 * @see com.tis.database.services.staging.ISdCustomerOutb1Services#NameSplitToSAP(java.lang.String)
	 * Date =Oct 28, 2013 : 11:43:30 AM 
	 * CreateBy=Chatree Siangklom
	 * TODO
	 */
	@Override
	public List<String> NameSplitToSAP(String name) throws Exception, HibernateException {
		// TODO Auto-generated method stub
		return sdCustomerOutb1Dao.NameSplitToSAP(name);
	}

	/** (Javadoc)
	 * @see com.tis.database.services.staging.ISdCustomerOutb1Services#UpdateBackSapMessage(java.util.List)
	 * Date =Nov 1, 2013 : 2:23:25 PM 
	 * CreateBy=Chatree Siangklom
	 * TODO
	 */
	@Override
	@Transactional(readOnly=false)
	public List<SdCustomerOutb1> UpdateBackSapMessage(List<SapMessage> sapMessages) throws HibernateException, Exception {
		// TODO Auto-generated method stub
		return sdCustomerOutb1Dao.UpdateBackSapMessage(sapMessages);
	}

	/** (Javadoc)
	 * @see com.tis.database.services.staging.ISdCustomerOutb1Services#SaveErrorToStaging(java.lang.String, sap.business.enumeration.STAGING_STATUS, java.lang.String)
	 * Date =Nov 1, 2013 : 3:48:53 PM 
	 * CreateBy=Chatree Siangklom
	 * TODO
	 */
	@Override
	@Transactional(readOnly=false)
	public void SaveErrorToStaging(String instanceNo, STAGING_STATUS Staging_STATUS, String error) {
		// TODO Auto-generated method stub
		sdCustomerOutb1Dao.SaveErrorToStaging(instanceNo, Staging_STATUS, error);
	}
	
}
